﻿using FarmSmartSleep.Common.Domain.RaiseManagement;
using FarmSmartSleep.Common.Dtos;
using FarmSmartSleep.Common.Infrastructure;
using MediatR;

namespace FarmSmartSleep.Organ.API.Application.RaiseCommands
{
    public class EliminateCreateHandler : IRequestHandler<EliminateCreateCommand, Result>
    {
        private readonly IBaseRepository<SheepCulled> sheepculledRep;

        public EliminateCreateHandler(IBaseRepository<SheepCulled> sheepculledRep)
        {
            this.sheepculledRep = sheepculledRep;
        }


        /// <summary>
        /// 羊只淘汰添加
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        public async Task<Result> Handle(EliminateCreateCommand request, CancellationToken cancellationToken)
        {
            var result = new Result() { Code = (int)CodeEnum.success };

            var data = await sheepculledRep.AddRange(request.SheepCulleds);

            result.Code = (int)CodeEnum.success;
            result.Data = data;
            return result;
        }
    }
}
